package day0724API;

import java.util.LinkedList;
import java.util.List;
import java.util.function.Consumer;

public class Test4 {
    public static void main(String[] args) {
        List<Character> list=new LinkedList<>();
        list.add('中');
        list.add('国');
        list.add('你');
        list.add('好');
        //可以用来循环集合元素的时候执行//  list.foreach(Consumer匿名内部类对象)
        Consumer co=new Consumer<Character>() {
            public void accept(Character character) {
                System.out.println(character);
            }
        };
        list.forEach(co);



        Consumer co2=(character)->System.out.println(character);
        list.forEach(co2);

    }
}

